package yh.common;

import lombok.Data;

/**
 * @author yh
 */
@Data
public class BaseTokenResult {
    private Integer code;

    private String message;

    private String token;

    private Object data;

    public BaseTokenResult(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public BaseTokenResult(Object data, String token) {
        this.data = data;
        this.token = token;
        this.code = 200;
        this.message = "success";
    }

    public BaseTokenResult(Integer code, String message, Object data, String token) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static BaseTokenResult success() {
        return new BaseTokenResult(200, "success");
    }

    public static BaseTokenResult success(Object data, String token) {
        return new BaseTokenResult(data, token);
    }

    public static BaseTokenResult error(WarningCode warningCode) {
        return new BaseTokenResult(warningCode.getCode(), warningCode.getMessage());
    }

    public static BaseTokenResult error(Integer code, String message) {
        return new BaseTokenResult(code, message);
    }
}
